package com.haidechizi.i18n.code.generator.common.message.utils;

import org.apache.commons.lang3.StringUtils;

/**
 * @author wangdejun
 * @create 2020/10/17 15:06
 */
public class RegexUtils {

    public static final String parseRegex(String data) {
        if (StringUtils.isBlank(data)) {
            return data;
        }
        return data.replaceAll("\\{", "\\\\{")
                .replaceAll("\\[", "\\\\[")
                .replaceAll("\\(", "\\\\(")
                .replaceAll("\\)", "\\\\)")
                .replaceAll("\\*", "\\\\*")
                .replaceAll("\\.", "\\\\.")
                .replaceAll("\\?", "\\\\?");
    }
}
